<template>
	<el-form ref="form" :rules="rules" :model="form" status-icon label-width="80px">
			<el-col :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
			<el-form-item label="服装规格" prop="clothing_specifications">
						<el-input id="clothing_specifications" v-model="form['clothing_specifications']" placeholder="请输入服装规格"
					v-if="user_group == '管理员' || (form['clothing_mall_id'] && $check_field('set','clothing_specifications') ) || $check_field('add','clothing_specifications')"></el-input>
				<div v-else-if="$check_field('get','clothing_specifications')">{{form['clothing_specifications']}}</div>
					</el-form-item>
		</el-col>
				<el-col :xs="24" :sm="12" :lg="8" class="el_form_item_warp">
			<el-form-item label="服装厂商" prop="clothing_manufacturers">
						<el-input id="clothing_manufacturers" v-model="form['clothing_manufacturers']" placeholder="请输入服装厂商"
					v-if="user_group == '管理员' || (form['clothing_mall_id'] && $check_field('set','clothing_manufacturers') ) || $check_field('add','clothing_manufacturers')"></el-input>
				<div v-else-if="$check_field('get','clothing_manufacturers')">{{form['clothing_manufacturers']}}</div>
					</el-form-item>
		</el-col>
	


		<el-col :xs="24" :sm="24" :lg="24" style="text-align: center;" class="el_form_btn_warp">
			<el-button type="primary" @click="submit()">提交</el-button>
			<el-button @click="cancel()">取消</el-button>
		</el-col>

	</el-form>
</template>

<script>
	import mixin from "../../mixins/component.js";

	export default {
		mixins: [mixin],
		props:{
			query: {
				type: Object,
				default: function(){
					return {
						"clothing_mall_id": 0
					}
				}
			},
			form_goods:{
				type: Object,
				default: function(){
					return {}
				}
			},
			func_check:{
				type: Function,
				default: function(fun){
					console.log("调试输出",fun);
				}
			},
			func_submit:{
				type: Function,
				default: function(fun){
					console.log("调试输出",fun);
				}
			}
		},
		data() {
			return {
				field: "clothing_mall_id",
				url_add: "~/api/clothing_mall/add?",
				url_set: "~/api/clothing_mall/set?",
				url_get_obj: "~/api/clothing_mall/get_obj?",
				url_upload: "~/api/clothing_mall/upload?",

				form: {
						"clothing_specifications":  '',
							"clothing_manufacturers":  '',
					},

		
				rules: {
					"clothing_specifications": [     {required: true,message: '服装规格不能为空'},  ],
					"clothing_manufacturers": [     {required: true,message: '服装厂商不能为空'},  ],
				}

			}
		},
		methods: {

			/**
			 * 请求列表前
			 * @param {Object} param
			 */
			get_list_before(param) {
				var user_group = this.user.user_group;
				if (user_group !== "管理员") {
					switch (user_group) {
												}
				}

				return param;
			},

	
	
		
	
	
			submit(){
				this.func_check(()=>{
					this.$refs["form"].validate((valid)} => {
						if (valid) {
							this.submit();
						} else {
							console.error('error 提交失败!!');
						}
					});
				})
			},

			submit_after(){
				var source_id = this.form_goods.source_id;
				if(source_id){
					this.func_submit();
				}else{
					this.$get('~/api/clothing_mall/get_obj?',this.form,(res)=>{
						if(res.result && res.result.obj){
							this.form_goods.source_id = res.result.obj["clothing_mall_id"];
							this.func_submit();
						}else{
							console.error(res.error);
						}

					})
				}
			}
		},
		created() {
				}
	}
</script>

<style>
	.avatar-uploader .el-upload {
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
	}

	.avatar-uploader .el-upload:hover {
		border-color: #409EFF;
	}

	.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		line-height: 178px;
		text-align: center;
	}

	.avatar {
		width: 178px;
		height: 178px;
		display: block;
	}
</style>
